home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 176-200 / scopedisk180 / arexxtutorial / string / string.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-19  |  2KB  |  60 lines

  1. /* print_at function demo
  2.         by Jim Ventola June 22, 1988
  3.  
  4.         emulates COMAL's PRINT AT <row, column> command
  5.          ...with help from SCARY and Bill Hawes */
  6.  
  7.                 
  8.             /* Main Program */
  9.  
  10. call open("jimsfile","con://640/60/Jim's CONSOLE; used for testing.")
  11. do for 5
  12.     call printat(2,13,"This should be at row 2, col 13. Hit return")
  13.     call getreturn()         /* Did user hit return? */
  14.     call printat(10,15,"And this line is at 10, 15. Hit Return")
  15.     call getreturn()
  16.     call page()
  17. end
  18. call printat(4,14,"All done.")
  19. call getreturn()
  20. exit
  21.  
  22.  
  23.         /* Internal (User Designed) Functions */
  24.  
  25. printat:procedure
  26. parse arg row, col, text /* To prevent conversion to upper case
  27.                 by ARG alone, which means PARSE UPPER ARG */
  28. s1 = (row)
  29. s2 = (col)
  30. outstring =  s1 || ';' || s2 || H || text /* Build ANSI coded string */
  31. call writech('jimsfile','9b'x||outstring) /* Write it to CON: file */ 
  32. return
  33.  
  34. page:
  35. call writech('jimsfile','0c'x)    /* Send formfeed to clear screen */
  36. return
  37.  
  38. getreturn:
  39.     do until char = '0A'x             /* OA hex is RETURN key */
  40.         char = readch("jimsfile")     /* wait for keypress */
  41.     end
  42. return
  43.  
  44.  
  45. /*                  Notes
  46.  
  47.     The CON: device responds to ANSI codes, as documented in an appendix
  48. of the Bantam DOS Manual.  Hex 9b ('9b'x in ARexx) is the Control
  49. Sequence Introducer (CSI). The docs give:"<CSI>row;columnH" as 
  50. the code for positioning the cursor.  That is what the outstring is
  51. all about--its assign code produces: '9b'x row;columnH text.
  52.     This demo also shows how to make and call an internal function. 
  53.  
  54.  Hint: if you get a lot of "unbalanced parentheses" errors 
  55. when you can SEE that there are two, check for a space between the 
  56. function name and the opening parenthesis.  ARexx is very strict
  57. about spaces. */
  58.  
  59.  
  60.